<?php
@session_start();
include_once '../../Model/M_Rubro.php';

include_once '../../Model/M_FormularioPorRol.php';
$pagina = $_REQUEST['idPag'];
$idUsuario = $_SESSION['id_usuario'];
$fxr = new M_FormularioPorRol();
$fxr->setidUsuario($idUsuario);
$fxr->setId_Pagina($pagina);
$listaPrivilegios = $fxr->searchVis_FormularioRol_Uno();
$flag_nuevo = 0;
$flag_modif = 0;
$flag_elim = 0;
for ($i = 0; $i < (count($listaPrivilegios)); $i++) {
    if ($listaPrivilegios[$i]['formulario'] == 'Registrar') {
        $flag_nuevo = 1;
    }
    if ($listaPrivilegios[$i]['formulario'] == 'Modificar') {
        $flag_modif = 1;
    }
    if ($listaPrivilegios[$i]['formulario'] == 'Eliminar') {
        $flag_elim = 1;
    }
}

$rubro = new M_Rubro();
$lista = $rubro->searchRubro_All();
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Mantenimiento Rubro</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <link rel="stylesheet" type="text/css" href="../css/style.css">
        <link rel="stylesheet" type="text/css" href="../css/principal.css">
        <link rel="stylesheet" type="text/css" href="../css/mantenedores.css"/>
        
        <script src="../media/js/jquery.js" type="text/javascript"></script>
        <script src="../media/js/jquery.dataTables.js" type="text/javascript"></script>
        
        <style type="text/css">
            @import "../media/css/demo_table_jui.css";
            @import "../media/themes/smoothness/jquery-ui-1.8.4.custom.css";
        </style>
        
        <style>
            *{
                font-family: arial;
                font-size: 8;
            }
        </style>
        <script type="text/javascript" charset="utf-8">
            $(document).ready(function(){
                $('#datatables').dataTable({
                    "sPaginationType":"full_numbers",
                    "aaSorting":[[0, "asc"]],
                    "bJQueryUI":true,
                    "oLanguage": {
                        "sLengthMenu": "Mostrar _MENU_ Registros",
                        "sZeroRecords": "No se encontraron registros",
                        "sInfo": "Mostrando _START_ de _TOTAL_ registros",
                        "sInfoEmpty": "Mostrando 0 de 0 registros",
                        "sInfoFiltered": "(Filtrado de _MAX_ registros totales)",
                        "sSearch": "Buscar:",
                        "oPaginate": {
                            "sFirst": "Primero", "sLast": "Último",  "sNext": "Siguiente", "sPrevious": "Anterior"
                        }
                    }
                });
            })
            
        </script>
        <script LANGUAGE="JavaScript">
            function confirmSubmit()
            {
                var agree = confirm("¿Desea realmente ELIMINAR este registro?");
                if (agree)
                    return true;
                else
                    return false;
            }
            // -->
        </script>
        <style>
            .ui-widget-header {
                border: 1px solid #aaaaaa;
                background: -webkit-gradient(linear,0 0,0 bottom,from(#fff),to(#efefef));
                background: -moz-linear-gradient(#fff,#efefef);
                background: linear-gradient(#fff,#efefef);
                color: #222222;
                font-weight: bold;
            }
            .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
                border: 1px solid #d3d3d3;
                background: -webkit-gradient(linear,0 0,0 bottom,from(#fff),to(#efefef));
                background: -moz-linear-gradient(#fff,#efefef);
                background: linear-gradient(#fff,#efefef);
                font-weight: normal;
                color: #555555;
            }
            .odd .sorting_1:hover,.even .sorting_1:hover, .odd:hover,.even:hover
            {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.odd td.sorting_1 {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.even td.sorting_1 {
                background: #f6f8f9;
                background: -moz-linear-gradient(top,  #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9));
                background: -webkit-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -o-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: -ms-linear-gradient(top,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                background: linear-gradient(to bottom,  #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 );
            }
            tr.odd{
                background: #eeeeee;
                background: -moz-linear-gradient(top,  #eeeeee 0%, #eeeeee 100%);
                background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#eeeeee));
                background: -webkit-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: -o-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: -ms-linear-gradient(top,  #eeeeee 0%,#eeeeee 100%);
                background: linear-gradient(to bottom,  #eeeeee 0%,#eeeeee 100%);
                filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#eeeeee',GradientType=0 );
            }
        </style>     
    </head>
    <body style="background: white;">       
        <div id='lineatitulo'>            
            <label align="center" style="font-weight: bold;">Mantenedor de Rubros </label>
        </div>
        <div id="lineaopciones">
            <?
            if($flag_nuevo == 1)
            {
            ?>
            <div>
            <div id="opciones_mant" align="center">
                <a  href="V_Rubro_I.php<?echo('?idPag='.$pagina);?>" title="Nuevo">
                    <img  class="imagen_mant" width="auto" height="35px" src="../images/Add.png">
                    <div class="leyenda_mant"><span> Nuevo </span></div>
                </a>                                
            </div>
            <div id="opciones_mant" align="center">
                <a href="V_Rubro_Excel" title="Reporte Excel">                    
                    <img class="imagen_mant" width="auto" height="35px" src="../images/excel.png">
                    <div class="leyenda_mant"><span> Imprimir Excel</span></div>
                </a>                                
            </div>
                <div style="clear: both;"></div>
            </div>
            <?}?>
        </div>               
         <br/>                   
        
            <table id="datatables" class="display" style="font-size: 10px">
                <thead>
                    <tr>
                        <th>NRO.</th>
                        <th align="left">NOMBRE</th>
                        <th width="5px">ACCIONES</th>
                       
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if (count($lista) > 0) {
                    for ($i = 0; $i < (count($lista)); $i++) {
                    ?>
                            <tr>
                                <td><?php echo $i + 1 ?></td>
                                <td align="left"><?php echo ($lista[$i]['nombre'].' <img width=11 height=11 src="../images/Rubro/'.$lista[$i]['imagen'].'"/>'); ?></td>
                                <td width="5px">
                            <? if ($flag_modif == 1) { ?>
                                        <a href="V_Rubro_U.php?idRubro=<?php echo ($lista[$i]['id_rubro'] . '&idPag=' . $pagina); ?>" title="Modificar"><img src="../images/icons/edit.png" alt="Edit"></a>
                            <? } ?>
                                
                                
                            <? if ($flag_elim == 1) { ?>
                                        <a href="../../Controller/C_Rubro_D.php?idRubro=<?php echo ($lista[$i]['id_rubro'] . '&idPag=' . $pagina); ?>" onClick="return confirmSubmit()" title="Eliminar"><img src="../images/icons/cross.png" alt="Delete"></a>
                                    <? } ?>
                            </td>
                            </tr>
                                    <?php
                                }
                            }
                            ?>
                </tbody>
            </table>
    </body>
</html>